﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace gChartSharp
{
    public class ChartDataSeries
    {

        public List<float> DataPoints { get; set; }


        public ChartDataSeries()
        {
            this.DataPoints = new List<float>();
        }


        public ChartDataSeries(float[] series)
        {
            this.DataPoints = new List<float>();

            foreach (float f in series)
                this.DataPoints.Add(f);
        }


        public ChartDataSeries(int[] series)
        {
            this.DataPoints = new List<float>();

            foreach (int i in series)
                this.DataPoints.Add((float)i);
        }


        // default to text encoding
        public string Render()
        {
            return Render(EncodingType.t);
        }

        public string Render(EncodingType encType)
        {
            StringBuilder sb = new StringBuilder();

            foreach (float f in this.DataPoints)
            {
                // TODO add multiple encoding types
                sb.Append(f.ToString());
                sb.Append(",");
            }

            // remove last ','
            if (sb.Length > 0)
                sb.Length--;

            return sb.ToString();
        }

     
    }
}
